package cn.edu.sptc.lichaoping.hellespring.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Controller
@RequestMapping("/data")
public class DataController {
    @RequestMapping(method = RequestMethod.GET,value = "/hello")
    @ResponseBody
    public String json(){
        return "返回数据是json字符串";
    }

    @GetMapping("/html")
    public String html(Model model){
      //  model.addAttribute("name","师姐");
        DateTimeFormatter dateTimeFormatter= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
        model.addAttribute("time",dateTimeFormatter.format(LocalDateTime.now()));

        return "home";
    }
}
